package com.qfedu.microorder.recharge.controller;
import com.qfedu.common.core.annotation.NoLogin;
import com.qfedu.common.core.common.R;
import com.qfedu.microorder.recharge.param.OrderPayParam;
import com.qfedu.microorder.recharge.service.OrderPayService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 调试一个初次见到的代码比重写代码要困难两倍。因此,按照定义,如果你写代码非常巧妙,那么没有人足够聪明来调试它。
 *
 * @author
 * @version 1.0
 * @date 2025/6/4 14:37
 */
@RestController
public class OrderPayController {
    @Resource
    private OrderPayService orderPayService;
    @PostMapping("/order/pay")
    public R createOrder(@RequestBody OrderPayParam orderPayParam){
        String orderPay = orderPayService.createOrderPay(orderPayParam);
        return R.ok(orderPay);

    }
    @NoLogin
    @PostMapping("/order/notify")
    public void orderNotify(HttpServletRequest request, HttpServletResponse response){
        orderPayService.notify(request, response);

    }
    @NoLogin
    @GetMapping("/order/return")
    public R returnNotify(HttpServletRequest request, HttpServletResponse response){
        orderPayService.returnNotify(request, response);
        return R.ok();

    }
    //查询交易订单支付状态
    @GetMapping("/order/check")
    public R checkOrderPayStatus(Integer payPlatform,String outTradeNo,Integer count){
        Integer ret = orderPayService.checkOrderPayStatus(payPlatform, outTradeNo,count);
        return R.ok(ret);
    }
}
